package com.darren.framework.dao.impl;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.query.Query;
import org.springframework.stereotype.Repository;

import com.darren.framework.dao.SystemParameterDao;
import com.darren.framework.entity.SystemParameter;


@Repository
public class SystemParameterDaoImpl extends GenericDaoImpl<SystemParameter, Long> implements SystemParameterDao {

	@Override
	public List<SystemParameter> getAll() {
		Session session = sessionFactory.getCurrentSession();	
		Query<SystemParameter> query  = session.createQuery(" from SystemParameter ",SystemParameter.class);
		return query.list();
	}
	
	@Override
	public SystemParameter getSystemParamter(String lookupCat,String lookupType){
		Session session = sessionFactory.getCurrentSession();	
		Query<SystemParameter> query  = session.createQuery(" from SystemParameter where lookupCat =:lookupCat and lookupType = :lookupType ",SystemParameter.class);
		query.setParameter("lookupCat", lookupCat);
		query.setParameter("lookupType", lookupType);
		List<SystemParameter> systemParameters = query.list();
		if(systemParameters != null && systemParameters.size() > 0){
			return systemParameters.get(0);
		}
		return null;
	}
	
}